/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package apus.command.person;

import apus.command.AbstractCommand;
import apus.entity.RealPerson;
import apus.persistence.PersonDAO;
import apus.services.ServiceLocator;
import java.util.Arrays;
import java.util.List;

/**
 * The <code>AddPersonCommand</code> class represents command for adding new 
 * person to the database.
 * @author  Maxim Vasilevsky
 * @author  Roman Dyatkovsky
 * @since APUS v0.4
 * @see AbstractCommand
 */
public class AddPersonCommand extends AbstractCommand{
    private final static String PARAM_NAME = "Name";
    private final static String PARAM_ADDRESS = "Address";
    private final static String PARAM_PASSPORT_NUMBER = "Passport number";
    
    private final static String[] paramsNames = { PARAM_NAME, 
                                                  PARAM_ADDRESS, 
                                                  PARAM_PASSPORT_NUMBER };
    
    public AddPersonCommand() {
        super("Add new person");
    }

    @Override
    public void execute() {
        PersonDAO personDAO = ServiceLocator.getService(PersonDAO.class);
        personDAO.create(new RealPerson(params.get(PARAM_PASSPORT_NUMBER),params.get(PARAM_NAME),params.get(PARAM_ADDRESS)));
    }
    
    @Override
    public List<String> getParamNames() {
        return Arrays.asList(paramsNames);
    }
    
}
